﻿
CREATE PROCEDURE [dbo].[P_OBTERLISTA_T10_SETOR_CATEGORIA]
	@cd_setor_categoria [int]
   ,@cd_setor [int]
   ,@cd_categoria [int]
   
AS
BEGIN
	SELECT
	T.cd_setor_categoria
    ,T.cd_setor
    ,T.cd_categoria
    ,t01.ds_categoria
    ,t09.ds_setor
  FROM T10_SETOR_CATEGORIA t
  inner join T09_SETOR t09 on t.cd_setor = t09.cd_setor
  inner join T01_CATEGORIA t01 on t.cd_categoria = t01.cd_categoria
  WHERE
    (t.cd_setor_categoria = @cd_setor_categoria OR @cd_setor_categoria IS NULL)
    AND (t.cd_setor = @cd_setor OR @cd_setor IS NULL)
    AND (t.cd_categoria = @cd_categoria OR @cd_categoria IS NULL)
    
END